package site.marqstree.kotlin.usercenter.ui.activity.resetpwd

import site.marqstree.kotlin.library.base.data.net.observer.RxObserver
import site.marqstree.kotlin.library.base.data.net.request.RxRequest
import site.marqstree.kotlin.library.base.extent.json2Boolean
import site.marqstree.kotlin.library.base.presenter.view.BasePresenter
import site.marqstree.kotlin.provider.common.ProviderConstant
import javax.inject.Inject


/*
 * 项目名: KotlinMall
 * 包名: site.marqstree.kotlin.usercenter.presenter
 * 文件名: ResetPwdPresenter
 * 创建者: marqstree
 * 创建时间: 2020/2/22 16:42
 * 描述: TODO
 */
/*
    重置密码Presenter
 */
class ResetPwdPresenter @Inject constructor() : BasePresenter<ResetPwdView>() {

    /*
        重置密码
     */
    fun resetPwd(mobile: String, password: String) {

        RxRequest.builder()
            .setUrl(ProviderConstant.RESET_PWD_URL)
            .setParam("mobile",mobile)
            .setParam("password",password)
            .post()
            .json2Boolean()
            .subscribe(object :RxObserver<Boolean>(){
                override fun onNext(data: Boolean) {
                    mView.onResetPwdResult("重置密码成功")
                }

                override fun onError(e: Throwable) {
                    mView.onResetPwdResult("重置密码失败")
                }
            })

    }

}